#include "JumpingCoin.h"

CJumpingCoin::CJumpingCoin() : CMovable()
{
	life = 0;
}

CJumpingCoin::	~CJumpingCoin()
{

}

void CJumpingCoin::Activate(float X,float Y)
{
	reality = 0;
	pos_x = X+4;
	pos_y = Y-16;
	v_y = -0.2f;
	v_x = 0;
	life = 1;
	lowest = pos_y;
	anim = 0;
}

void CJumpingCoin::RenderFrame(LPDIRECT3DDEVICE9 d3ddv,int t)
{
	DWORD now = GetTickCount();
	Update(t);
	if (now - last_time > 30)
	{
		anim=(anim+1) % 4;
		last_time = now;
	}
	SpriteHandlerIP->Begin(D3DXSPRITE_ALPHABLEND);
	ItemPic->Render(_BackBuffer,pos_x,pos_y,3,anim);
	SpriteHandlerIP->End();
}

void CJumpingCoin::Update(int t)
{
	pos_x += v_x*t;
	pos_y += v_y*t;
	if(lowest - pos_y >= 20)
	{
		v_y = 0;
		life = 0;
	}
}